home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2000 January / maximum-cd-2000-01.iso / Dreamweaver2 / data1.cab / Program_Files / Configuration / Behaviors / Actions / Swap Image Restore.js < prev    next >
Encoding:
JavaScript  |  1999-02-23  |  1.6 KB  |  55 lines

  1. // Copyright 1998 Macromedia, Inc. All rights reserved.
  2.  
  3. //*************** GLOBALS VARS *****************
  4.  
  5. //******************* BEHAVIOR FUNCTION **********************
  6.  
  7. //Restores a set of images to their previous source files.
  8. //Accepts a variable number of params, in pairs read from a global property:
  9. //  objStr - Javascript object ref for an image (ex: document.myImage)
  10. //  imgURL - original image filename, URL encoded. (ex: file.gif, http://www.x.com/y.gif)
  11. //
  12. //This is the companion Action to Swap Image. Swap Image gathers the original
  13. //image src filenames, and writes document.MM_swapImageData before changing the images.
  14. //This sets the images src properties back to their original filenames:
  15. //  document.myImage.src = file.gif.
  16.  
  17. function MM_swapImgRestore() { //v2.0
  18.   if (document.MM_swapImgData != null)
  19.     for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
  20.       document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
  21. }
  22.  
  23.  
  24. //******************* API **********************
  25.  
  26.  
  27. //Checks for the existence of images.
  28. //If none exist, returns false so this Action is grayed out.
  29.  
  30. function canAcceptBehavior(){
  31.   var nameArray = getObjectRefs("NS 4.0","document","IMG");  //get array of image names
  32.   return (nameArray.length > 0);
  33. }
  34.  
  35.  
  36.  
  37. //Returns a Javascript function to be inserted in HTML head with script tags.
  38.  
  39. function behaviorFunction(){
  40.   return "MM_swapImgRestore";
  41. }
  42.  
  43.  
  44.  
  45. //Returns simple fn call, no args
  46. function applyBehavior() {
  47.   return "MM_swapImgRestore()";
  48. }
  49.  
  50.  
  51.  
  52. //Passed the function call above, does nothing (no args to handle)
  53. function inspectBehavior(){
  54. }
  55.